package scu.maqiang.visualization;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
public class SetAxisFrame extends JPanel {
 
	public SetAxisFrame() {
		this.setBackground(Color.WHITE);

	}
	
	
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
 
        Graphics2D g2d = (Graphics2D)g;
 
        g2d.translate(getWidth() / 2, getHeight() / 2);
        g2d.scale(1, -1);
//         g2d.setColor(Color.WHITE);
//        g2d.fillRect(-getWidth() / 2, -getHeight() / 2, getWidth(), getHeight());
//        g2d.setColor(Color.BLACK);
        g2d.drawLine(-getWidth() / 2, 0, getWidth() / 2, 0);
        g2d.drawLine(0, -getHeight() / 2, 0, getHeight()/2);
        g2d.fillRect(0, 0, 100, 100);
        
    }
 
    private static void createAndShowGUI() {
        JFrame frame = new JFrame();
 
        // Add your component.
        frame.setContentPane(new SetAxisFrame());
 
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setBackground(Color.white);
        frame.setSize(600, 600);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
 
    public static void main(String[] args) throws IOException {
        createAndShowGUI();
    }
}